#include <iostream>
#include <algorithm>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>

using namespace std;

int linearSearch (int *array, int key, int size)
{
    static int index = 0;
    if (size == 0) return -1;
    if (*array == key) return index;
    index++;
    return linearSearch (array + 1, key, size - 1);
}

int main()
{
    const int SIZE = 10;
    srand ((unsigned)time(NULL));
    int array[SIZE];
    generate_n (array, SIZE, rand);
    
    for (int i = 0; i < SIZE; ++i)
        cout << array[i] << " ";
    cout << endl;

    cout << endl << linearSearch (array, 10, SIZE) << endl;

    return 0;
}

